/*
	FileName : JT_C_REC_Ver.c
	Description :
		Manage the JT_C Version record.
	
	Created on 2017.11.05 by WFL.

	Revision History:

*/


/* Includes ------------------------------------------------------------------*/



#include "JT_C_REC_Ver.h"


uint8_t JTC_ver[JTC_VER_TOTAL_LEN];


//------------------------------------------------------------------------------
void JTC_REC_VER_getWhole(uint8_t *readBuf, uint8_t *verBuf)
{
	uint32_t i;
	for(i=0; i< (JTC_VER_UNIT_TOLNUMBER*JTC_VER_UNIT_LEN); i++)
		readBuf[i] = verBuf[i];
	return;
}
void JTC_REC_VER_setWhole(uint8_t *writeBuf, uint8_t *verBuf)
{
	uint32_t i;
	for(i=0; i< (JTC_VER_UNIT_TOLNUMBER*JTC_VER_UNIT_LEN); i++)
		verBuf[i] = writeBuf[i];
	return;
}
//------------------------------------------------------------------------------
void JTC_REC_VER_setUnitByUart(uint8_t *uartVerDataAddr, uint8_t *verBuf, uint8_t unit)
{
	uint32_t i;
	
	i = unit * JTC_VER_UNIT_LEN;
	
	if((i+JTC_VER_UNIT_LEN) > JTC_VER_TOTAL_LEN)
		return;		///error offset
	
	uartVerDataAddr++;///Version type(BIOS or APP)
	verBuf[i++] = *uartVerDataAddr++;///main
	verBuf[i++] = *uartVerDataAddr++;///sub
	uartVerDataAddr++;///Year---2000
	verBuf[i++] = *uartVerDataAddr++;///Year
	verBuf[i++] = *uartVerDataAddr++;///Month
	verBuf[i++] = *uartVerDataAddr++;///Date
	verBuf[i++] = *uartVerDataAddr++;///Build
	verBuf[i++] = *uartVerDataAddr++;///Sub Build
	return;
}

const uint8_t JTC_VER_uartUNIT_order[JTC_VER_uartUNIT_CNT] = 
	{	JTC_VER_UNIT_SAM_BIOS,	JTC_VER_UNIT_SAM_APP,	JTC_VER_UNIT_ACTRL_BIOS,
		JTC_VER_UNIT_ACTRL_APP,	JTC_VER_UNIT_AJM1_BIOS,	JTC_VER_UNIT_AJM1_APP,
		JTC_VER_UNIT_AJM2_BIOS,	JTC_VER_UNIT_AJM2_APP,	JTC_VER_UNIT_BCTRL_BIOS,
		JTC_VER_UNIT_BCTRL_APP,	JTC_VER_UNIT_BJM1_BIOS,	JTC_VER_UNIT_BJM1_APP,
		JTC_VER_UNIT_BJM2_BIOS,	JTC_VER_UNIT_BJM2_APP,	JTC_VER_UNIT_LJB_BIOS,
		JTC_VER_UNIT_LJB_APP};

void JTC_REC_VER_setByUart(uint8_t *uartVerDataAddr, uint8_t *verBuf)
{
	uint8_t i;
	for(i = 0; i< JTC_VER_uartUNIT_CNT; i++)
	{
		JTC_REC_VER_setUnitByUart(uartVerDataAddr, verBuf, JTC_VER_uartUNIT_order[i]);
		uartVerDataAddr += JTC_VER_uartUNIT_LEN;		
	}
	return;
}
//-----------------------------------------------------------------------------------------
void JTC_REC_VER_init(uint8_t *j_Ver)
{
	uint32_t i;
	
	for(i=0; i< JTC_VER_TOTAL_LEN; i++)
		j_Ver[i] = 0;
	return;
}

///EOF
